package com.dlwx.parttimetalent.views;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.dlwx.parttimetalent.R;
import com.dlwx.parttimetalent.inter.DialogPayInter;
import com.flyco.dialog.widget.base.BottomBaseDialog;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * Created by Administrator on 2017/11/24.
 */

public class PayTypeDialog extends BottomBaseDialog {

    @BindView(R.id.image_alipay)
    ImageView imageAlipay;
    @BindView(R.id.rl_alipay)
    RelativeLayout rlAlipay;
    @BindView(R.id.image_weixin)
    ImageView imageWeixin;
    @BindView(R.id.rl_weixin)
    RelativeLayout rlWeixin;
    @BindView(R.id.tv_confirm)
    TextView tvConfirm;
    @BindView(R.id.tv_cancel)
    TextView tvCancel;
    @BindView(R.id.image_yuer)
    ImageView imageYuer;
    @BindView(R.id.rl_yuer)
    RelativeLayout rlYuer;
    private Context context;
    private int  payType = 1;
    private DialogPayInter inter;

    public PayTypeDialog(Context context, DialogPayInter inter) {
        super(context);
        this.context = context;
        this.inter = inter;
    }

    @Override
    public View onCreateView() {
        View view = LayoutInflater.from(context).inflate(R.layout.dialog_pay_type, null);
        ButterKnife.bind(this, view);
        return view;
    }

    @Override
    public void setUiBeforShow() {
        imageWeixin.setImageResource(R.mipmap.icon_xuanze);
        imageYuer.setImageResource(R.mipmap.icon_xuanze);
        imageAlipay.setImageResource(R.mipmap.icon_xuanzhong);
        payType = 1;
    }

    @OnClick({R.id.rl_alipay, R.id.rl_weixin, R.id.tv_confirm, R.id.tv_cancel,R.id.rl_yuer})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.rl_alipay:
                imageWeixin.setImageResource(R.mipmap.icon_xuanze);
                imageYuer.setImageResource(R.mipmap.icon_xuanze);
                imageAlipay.setImageResource(R.mipmap.icon_xuanzhong);
                payType = 1;
                break;
            case R.id.rl_weixin:
                imageAlipay.setImageResource(R.mipmap.icon_xuanze);
                imageYuer.setImageResource(R.mipmap.icon_xuanze);
                imageWeixin.setImageResource(R.mipmap.icon_xuanzhong);
                payType =2;
                break;
            case R.id.rl_yuer:
                imageAlipay.setImageResource(R.mipmap.icon_xuanze);
                imageWeixin.setImageResource(R.mipmap.icon_xuanze);
                imageYuer.setImageResource(R.mipmap.icon_xuanzhong);
                payType =3;
                break;
            case R.id.tv_confirm:
                cancel();
                inter.payType(payType);
//                context.startActivity(new Intent(context,PaySuccessActivity.class));
                break;
            case R.id.tv_cancel:
                cancel();
                break;
        }
    }
}
